package top.mingtea.propertymannagement.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.mingtea.propertymannagement.pojo.property_fee;
import top.mingtea.propertymannagement.service.property_feeService;

import java.util.List;

@RestController
@RequestMapping("/propertyFee")
public class property_feeController {
    @Autowired
    private final property_feeService propertyFeeService;

    public property_feeController(property_feeService propertyFeeService) {
        this.propertyFeeService = propertyFeeService;
    }

    @GetMapping("/getlist")
    public List<property_fee> getAll() {
        return propertyFeeService.getAll();
    }

    @PostMapping("/add")
    public void add(@RequestBody property_fee propertyFee) {
        propertyFeeService.add(propertyFee);
    }

    @DeleteMapping("/remove/{buildingId}/{houseId}")
    public void remove(@PathVariable("buildingId") int building_id, @PathVariable("houseId") int house_id) {
        propertyFeeService.remove(building_id, house_id);
    }

    @PutMapping("/update")
    public void update(@RequestBody property_fee propertyFee) {
        propertyFeeService.update(propertyFee);
    }
}
